package com.yupi.yuojcodesandbox;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class Main {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> future1 = CompletableFuture.supplyAsync(() -> {

            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("有返回值的异步任务1");
            return "asyn task1";
        });

        String s = future1.get();
        String join = future1.join();
        System.out.println(join);
        System.out.println(s);
        System.out.println("Main线程...");
        Thread t1 = new Thread();
    }
}
